/**
 * @Author: Caven
 * @Date: 2020-01-21 16:10:47
 */
import mapImage from '@/assets/js/map/mapImagery.js'
class TencentImageryProvider extends Cesium.UrlTemplateImageryProvider {
  constructor(options = {}) {
    options['url'] = options.mapImage.url || mapImage['腾讯地图-电子图经典风格'].url
    if (!options.subdomains || !options.subdomains.length) {
      options['subdomains'] = ['0', '1', '2']
    }
    if (options.isImage) {
      options['customTags'] = {
        sx: (imageryProvider, x, y, level) => {
          return x >> 4
        },
        sy: (imageryProvider, x, y, level) => {
          return ((1 << level) - y) >> 4
        }
      }
    }
    super(options)
  }
}

export default TencentImageryProvider
